home *** CD-ROM | disk | FTP | other *** search
- Path: news.iadfw.net!usenet
- From: Larry Weiss <lfw@iadfw.net>
- Newsgroups: comp.lang.c
- Subject: Re: Determining the length of an int in string form
- Date: Sun, 24 Mar 1996 17:53:11 -0600
- Organization: customer of Internet America
- Message-ID: <3155E067.3261@iadfw.net>
- References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net> <4in1ga$ogk@airdmhor.gen.nz> <Pine.SOL.3.91.960319172332.4535A-100000@darwin.UCSC.EDU> <314F65D3.6A8@oc.com> <827703345snz@genesis.demon.co.uk>
- NNTP-Posting-Host: dal25-03.ppp.iadfw.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (Win16; I)
-
- Lawrence Kirby wrote:
- >
- > In article <314F65D3.6A8@oc.com> lfw@oc.com "Larry Weiss" writes:
- > >I've seen some suggestions to try to fprintf() once to a file (maybe a
- > >"bit-bucket") to get a handle on how many characters sprintf() may use,
- > >but I don't think that that's guaranteed by the C Standard to absolutely
- > >correspond.
- >
- > I think it must. 7.9.6.5:
- >
- > "The sprintf function is equivalent to fprintf, except that the argument s
- > specifies an array into which the generated output is to be written,
- > rather than to a stream."
- >
- > So the same number of characters are being written/output in both cases,
- > unless a write error occurred in fprintf which you can detect.
- >
-
-
- We all discussed this, maybe a year ago, and what I was remembering was
- the issue with the representation of end-of-line on the file system, and
- whether this affected the return value of fprintf(). Seems safe enough
- that if you never indicate the end-of-line condition (usually via the
- \n in in format string) then that is not an issue (even on a mainframe,
- with those block-mode fixed-length records).
-
- Now what I'd really like to see in the next revision of the standard library
- would be an snprintf() with the extra argument to declare only so many writeable
- chars in the buffer, and a return code to indicate logical attempts to write
- beyond that limit.
-